package com.youshang520i.springconfigclient;

import com.youshang520i.springconfigclient.model.ClientConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;

@RestController
@SpringBootApplication
public class SpringConfigClient {

    public static void main(String[] args) {
        SpringApplication.run(SpringConfigClient.class, args);
    }

    @Value("${my.username}")
    private String userName;
    @Autowired
    private ClientConfig clientConfig;


    @PostConstruct
    public void init(){
        System.out.println(userName);
    }

    @GetMapping("/")
    public String getUserName(){
        return clientConfig.toString();
    }

}
